<template>
    <div class="accept_share_bt" @click="on_accept_share">
        <div class="left">
            <slot name="left"></slot>
        </div>
        <div class="right">
            接受
        </div>
    </div>
</template>
<script>
export default { //接受分享按钮组件
    name:'Accept_share_bt',
    data(){
        return{

        };
    },
    created(){

    },
    methods:{
        on_accept_share(){ //接受分享按钮组件
            this.$store.commit('set_loading',{
                state:true,
                msg:'请稍后',
            });
            this.$axios.json_post('shared/recept',{
                fileShare:this.$store.state.selection_files,
            }).then(({data})=>{
                for(let a of data){
                    setTimeout(() => {
                        this.$store.commit('add_accept_share_file',{
                            file:{
                                name:a.fileName,
                            },
                            msg:a.msg || '接受成功',
                            state:a.sate==1?'success':'fail',
                        });
                    },0);
                }
                this.$store.state.update_data = !this.$store.state.update_data;
            }).catch((msg)=>{
                this.$message({
                    type: 'error',
                    message: msg,
                    offset:65,
                    showClose:true,
                });
            }).finally(()=>{
                this.$store.commit('set_loading',{
                    state:false,
                });
            });
        },
    },
}
</script>
<style lang="scss" scoped>
.accept_share_bt{
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    line-height: 100%;
    cursor: pointer;
    padding: 0 10px;
    box-sizing: border-box;
    >div{
        display: flex;
        justify-content: center;
        align-items: center;
    }
    i{
        width: 24px;
        height: 24px;
        margin-right: 5px;
    }
}
</style>